package com.machine.action.component;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.machine.bean.Componentpart;
import com.machine.service.user.ComponentServiceDao;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 *�����㲿������
 */

@Component("updateComAction")
@Scope(value = "prototype")
public class UpdateComAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ComponentServiceDao componentServiceDao;
	private Componentpart componentpart;
	private List<Integer> componentpartsId = new ArrayList<Integer>();

	
	public Componentpart getComponentpart() {
		return componentpart;
	}

	public void setComponentpart(Componentpart componentpart) {
		this.componentpart = componentpart;
	}

	public ComponentServiceDao getComponentServiceDao() {
		return componentServiceDao;
	}

	@Resource(name = "componentService")
	public void setComponentServiceDao(ComponentServiceDao componentServiceDao) {
		this.componentServiceDao = componentServiceDao;
	}

	public List<Integer> getComponentpartsId() {
		return componentpartsId;
	}

	public void setComponentpartsId(List<Integer> componentpartsId) {
		this.componentpartsId = componentpartsId;
	}

	@Override
	public String execute() throws Exception {
		System.out.println("updateComAction id : " + componentpartsId);
		
		if(componentpartsId.size() > 0){
			componentpart = componentServiceDao.findById(componentpartsId.get(0));
			//System.out.println("componentpart : " + componentpart.getName());
			//System.out.println("provider name : " + componentpart.getProvidername());
		}
		return SUCCESS;
	}

}
